package com.siwei.mes.controller;

import com.siwei.mes.common.query.PageQuery;
import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.common.validator.PageGroup;;
import com.siwei.mes.entity.tgl.TglTrwd;
import com.siwei.mes.service.TglTrwdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * TGL任务单控制层
 *
 * @author yangke
 * @since 2023-11-30 15:45:00
 */
@Api(value = "TGL任务单")
@RestController
@RequestMapping("tglTrwd")
public class TaskController {
    @Resource
    private TglTrwdService tglTrwdService;

    @ApiOperation(value = "分页获取TGL任务单")
    @PostMapping("/page")
    public Json appPage(@RequestBody @Validated(PageGroup.class) PageQuery<TglTrwd, TglTrwd> query) {
        return Json.succ().data(tglTrwdService.getPage(query));
    }

    @ApiOperation(value = "根据主键id获取TGL任务单")
    @GetMapping("loadById")
    public Json loadById(@RequestParam("id") Long id) {
        return Json.succ().data(tglTrwdService.loadById(id));
    }

    @ApiOperation(value = "获取所有TGL任务单")
    @PostMapping("getAll")
    public Json getAll(@RequestBody TglTrwd entity) {
        return Json.succ().data(ApiResult.addList(tglTrwdService.getAll(entity)));
    }
}
